package com.hktf.moedokilock.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hktf.corelib.utils.LogMds;
import com.hktf.moedokilock.R;
import com.hktf.moedokilock.bean.MineItem;

import java.util.List;

/**
 * @包名称： com.cdz.bluetooth.adapter
 * @类名： BluetoothViewAdapter
 * @创建人： 陈大专
 * @时间： 2021/08/17 14:06
 * @描述：
 */
public class MineAdapter2 extends BaseQuickAdapter<MineItem, BaseViewHolder> {
    public MineAdapter2(@Nullable List<MineItem> data) {
        super(R.layout.mine_item2,data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MineItem item) {

        helper.setText(R.id.tv1, "");
        helper.setText(R.id.tv2, "");
        helper.setGone(R.id.iv1,false);
        if (item.getItemType()==1) {
            helper.setGone(R.id.view,true);
            helper.setGone(R.id.iv,false);
            helper.setGone(R.id.tv2,false);
            helper.setGone(R.id.iv_toggle,true);
            helper.setText(R.id.tv, item.getTitle());
            helper.setText(R.id.tv1, item.getValue1());
            LogMds.e("cdz", "点击了：" + item.getTitle()+">>>"+item.isChecked());
//            helper.setImageResource(R.id.iv_toggle,item.isChecked()?R.drawable.toggle_on:R.drawable.toggle_off);
        }else if(item.getItemType()==2){
            helper.setGone(R.id.view,false);
            helper.setGone(R.id.iv,false);
            helper.setGone(R.id.tv2,false);
            helper.setGone(R.id.iv_toggle,false);
            helper.setText(R.id.tv, item.getTitle());
        }else  {
            helper.setGone(R.id.view,false);
            helper.setGone(R.id.iv,false);
            helper.setGone(R.id.tv2,true);
            helper.setGone(R.id.iv_toggle,false);
            helper.setText(R.id.tv, item.getTitle());
            helper.setImageResource(R.id.iv, item.getResId());
            helper.setText(R.id.tv1, item.getValue1());
            helper.setText(R.id.tv2, item.getValue2());
        }

        if(item.getItemType()==3){
            helper.setGone(R.id.iv1,item.isChecked());
        }

        helper.setGone(R.id.view,item.isShowMargin());
        helper.setGone(R.id.line,item.isShowLine());
        helper.setBackgroundRes(R.id.rl,item.getImgSelectedResId());

    }
}
